-- rape.lua
-- Sam - 2007

---------------------------------------

-- set up all command prefixes
cmdNames = {
    "rape"
}


COOLDOWN = 5 -- plugin cooldown, 0 for none
bot_name = "YourMum"
bot_desc = "bot description here"
bot_email = "bot@nowhere.com"
use_bot = false

function doCommand(nick, data, z)
    
    -- insert coad here before cooldown check
    if (ready(nick)) then
        return true
    end
    -- insert other code here below cooldown check
    
    if (string.len(data) < 1) then
        return true
    end
    
    message = "/me rapes "..data.." with "..adjective[math.ceil(math.random(1, table.getn(adjective)-1))]..epeen[math.ceil(math.random(1, table.getn(epeen)-1))].."."
    SendMessageToHub(message, nick)
end

function doHelp(nick)
    SendMessageToUser("Usage: ", nick, bot_name)
    DisplayHelpMessage("help", "Shows this message.", nick)
    -- put coad in here for help commands:
    displayHelpMessage("<username>", "Rapes username with a random object.", nick)
end

-- insert other functions here

adjective = {
        "a massive ",
        "a tiny ",
        "a very large, massive, engorged, inflated ",
        "a dripping ",
        "a HARDCORE "
    }

epeen = {
        "penis",
        "rickety varandah",
        "broom",
        "splintered broom",
        "GAME OF DOTA",
        "pool cue",
        "unarmed civilian",
        "bicycle",
        "wooden mallet",
        "fist. (up to the elbow) :O",
    }

---------------------------------------
-- you can ignore below here
timeLeft = 0 

function Main()
    -- Check if script should add a new bot.
    if (use_bot) then
    -- Add new bot.
        VH:AddRobot(bot_name, 10, bot_desc, "Bot ", bot_email, "0")
    end
end

function UnLoad()
	if (use_bot) then
    	VH:DelRobot(bot_name)
	end
end

function VH_OnParsedMsgChat(nick, data)
    for i=1, table.maxn(cmdNames), 1 do
		if (string.find(data, "^%."..cmdNames[i])) then
		    _,_,cmd = string.find(data, "^%."..cmdNames[i].."%s(.+)")
		    if (cmd == "help") then
		        doHelp(nick)
		    else
        		doCommand(nick, cmd, cmdNames[i])
        	end
    		return 0
    	end
	end
	return 1
end

function ready(nick)
    if (timeLeft == 0) then
		timeLeft = COOLDOWN
	else
		SendMessageToUser("This command can only be used every "..COOLDOWN.." seconds.  You have "..timeLeft.." seconds to wait.", nick, bot_name)
		return true
	end
	return false
end

function SendMessageToHub(data, from)
	return VH:SendDataToAll("<"..from.."> "..data.."|",0,10)
end

function SendMessageToUser(data, nick, from)
	return VH:SendDataToUser("<"..from.."> "..data.."|", nick)
end

function SendPrivateMessageToUser(user, data, from)
    return VH:SendDataToUser("$To: "..user.." From: "..from.." $<"..from.."> "..data.."|", user);
end

function DisplayHelpMessage(cmd, msg, nick)
    SendMessageToUser("        ."..cmdNames[1].." "..cmd, nick, bot_name)
    SendMessageToUser("        "..msg, nick, bot_name)
end

function VH_OnTimer()
	if (timeLeft > 0) then
		timeLeft = timeLeft - 1
	end
	return 1
end